package com.zhou.controller;

import com.zhou.domain.Dto.PageDto;
import com.zhou.domain.FlightPath;
import com.zhou.service.impL.FlightPathServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import zhongbo.java.air.common.vo.PageVo;
import zhongbo.java.air.common.vo.ResultVo;


@Api(tags = "飞行轨迹相关接口")
@RestController
@RequestMapping("/flightpath")
public class FlightPathController {

    @Autowired
    private FlightPathServiceImpl flightPathService;

    //分页查寻
    @GetMapping("/slelec")
    @ApiOperation(value = "飞行轨迹信息列表", notes = "分页查询", httpMethod = "GET", response = ResultVo.class)
    private ResultVo<PageVo<FlightPath>> selectPage(int pageNum, int pageSize, String sortField, boolean isAsc){
        PageDto pageDto = new PageDto(pageNum, pageSize, sortField, isAsc);
        PageVo<FlightPath> airportPageVo = flightPathService.selectPage(pageDto);
        return ResultVo.ok(airportPageVo);
    }

    //新增
    @PostMapping("/add")
    @ApiOperation(value = "新增飞行轨迹信息", notes = "添加", httpMethod = "POST", response = ResultVo.class)
    private ResultVo<Object> add(@RequestBody FlightPath flightPath){
        flightPathService.add(flightPath);
        return ResultVo.ok(null);
    }

    //删除
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除飞行轨迹", notes = "删除", httpMethod = "DELETE", response = ResultVo.class)
    private ResultVo<Object> delete(@PathVariable String id){
        flightPathService.deleteById(id);
        return ResultVo.ok(null);
    }

    //修改
    @PutMapping("/update")
    @ApiOperation(value = "修改飞行轨迹信息", notes = "删除", httpMethod = "PUT", response = ResultVo.class)
    private ResultVo<Object> update(@RequestBody FlightPath flightPath){
        flightPathService.update(flightPath);
        return ResultVo.ok(null);
    }
}
